<template>
  <transition name="fade">
    <div id="preview" class="layui-layer-page layui-layer-prompt edit-content" v-show="isShow">
      <div class="layui-layer-title">请输入引用内容</div>
      <div class="layui-layer-content">
        <div class="detail-body" v-html="replaceHtml"></div>
      </div>
      <span class="layui-layer-setwin" @click.stop="close()">
        <a href="javascript:void(0)" class="layui-layer-ico layui-layer-close layui-layer-close1"></a>
      </span>
    </div>
  </transition>
</template>

<script>
import { escapeHtml } from '@/util/escapeHtml'
export default {
  name: 'preview',
  props: ['isShow', 'content'],
  computed: {
    replaceHtml () {
      if (typeof this.content === 'undefined' || this.content.trim() === '') {
        return ''
      }
      return escapeHtml(this.content)
    }
  },
  methods: {
    close () {
      this.$emit('cancel')
    }
  }
}
</script>

<style lang="scss" scoped>
#preview{
  position: fixed;
  width: 100%;
  height: 100%;
  background: #fff;
  left: 0;
  top: 0;
}
</style>
